import axios from "@/utils/serviceClient";
import { encodeSearchParams, isReallyNull } from "@/utils/utils";

function wxRequest(params, url) {
  params = { ...params };
  //params.companysysno = 1717;
  url = `${url}?companySysNo=${params.companysysno}`;
  if (
    params.method &&
    params.method.toLowerCase() === "get" &&
    !isReallyNull(params.data)
  ) {
    return axios.get(`${url}&${encodeSearchParams(params.data)}`);
  } else if (params.method && params.method.toLowerCase() === "post") {
    return axios.post(`${url}`, params.data);
  } else {
    return axios.get(`${url}`);
  }
}
const getShoppingMallConfig = params =>
  wxRequest(params, "/Common/GetMallHomeConfig");
const getWebHomeConfig = params => {
  let data = { companysysno: params };
  return wxRequest(data, "/Common/GetWebSiteHomeConfig");
};
const getActivityConfig = params =>
  wxRequest(params, "/Common/GetActivityConfig");
const getProductCoptData = params =>
  wxRequest(params, "/Common/GetProductCoptData");
const GetProductTagCoptData = params =>
  wxRequest(params, "/Common/GetProductTagCoptData");
const getProductData = params => wxRequest(params, "/Common/GetProductData");
const getNews = params => wxRequest(params, "/Common/GetNews");

const getCouponsData = params => wxRequest(params, "/Common/GetCouponsData");

const getFourNews = () => wxRequest(null, "/Common/GetFourNews");
// 链接页面
const NgtDiyPage = params => wxRequest(params, "/Common/GetDiyPageConfig");
// 链接标签
const NgtProductTagPage = params =>
  wxRequest(params, "/Common/GetProductTagConfig");
// 链接产品
const NgtProduc = params => wxRequest(params, "/Common/GetProductConfig");
// 链接系列产品
const NgtSeriesProduct = params => wxRequest(params, "/Common/GetSeriesConfig");
// 链接风格产品
const NgtStylesProduct = params => wxRequest(params, "/Common/GetStylesConfig");
// 链接类别产品
const NgtCategoryProduct = params =>
  wxRequest(params, "/Common/GetCategoryConfig");
const cardAppMenuEnableGetPhone = () =>
  wxRequest({ showLoadding: false }, "/Common/CardAppMenuEnableGetPhone");
const getPageConfig = params => wxRequest(params, "/Common/GetPageConfig");

const getAllWxApplet = () =>
  wxRequest({ showLoadding: false }, "/Common/GetAllWxApplet");
const tabBarHadClassify = () =>
  wxRequest({ showLoadding: false }, "/Common/TabBarHadClassify");
export default {
  getShoppingMallConfig,
  getWebHomeConfig,
  getActivityConfig,
  getProductCoptData,
  GetProductTagCoptData,
  getNews,
  getFourNews,
  NgtDiyPage,
  NgtProductTagPage,
  NgtProduc,
  NgtSeriesProduct,
  NgtStylesProduct,
  NgtCategoryProduct,
  getProductData,
  cardAppMenuEnableGetPhone,
  getAllWxApplet,
  getPageConfig,
  tabBarHadClassify,
  getCouponsData
};
